<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>contains</title>
<style type="text/css">
	body {background-color: white; color: black; font-family:sans-serif; font-size:medium;}
	a:link {color: #3300ff;}
	a:visited {color: #663399;}
	a:hover {color:#0099ff;}
	a:active {color: #0066cc;}
	a.button {text-decoration:none;}
	
	table.nav  {background-color: #dbddff;}
	table.body {margin-top:2ex; margin-bottom:2ex;}
	table.programlistingindent {margin-left:32px;}
	
	img { margin-bottom:0px; margin-top:0px;}
	tt {margin-left:0.5em; margin-right:0.5em; font-weight:lighter;}
	
	p {margin-top:0ex;}
	p.synopsis {margin-left:32px;}
	p.programlistingindent {margin-left:32px;}
	p.citetitle {margin-left:2em;}
	
	ul ul {list-style-type:square;}
	ul li p {margin-top:0ex; margin-bottom:.5ex; padding:0}
	ol li p {margin-top:0ex; margin-bottom:.5ex; padding:0}
	
	h1.reftitle {color:#a90000;}
	h1.reftitle {font-size:3.7ex; margin-top:0; margin-bottom:0; font-weight:bold}
	h1.title {color:black; font-size:4ex; margin-top:1ex; font-weight:bold}
	h2.title {color:#bd0000; margin-top:1ex; margin-bottom:.9ex; font-weight:bold; font-size:3ex}
	h3.title {color:#bd0000; margin-top:1ex; margin-bottom:.9ex; font-weight:bold; font-size:2.5ex}
	h4.title {color:#bd0000; margin-top:1ex; margin-bottom:.9ex; font-weight:bold; font-size:2ex}
	h2 {color:#bd0000; margin-top:1ex; margin-bottom:.9ex; font-weight:bold; font-size:2.5ex}
	h3 {color:#bd0000; margin-top:1ex; margin-bottom:.9ex; font-weight:bold; font-size:2ex} 
	
	pre.programlisting {margin-left:32px;}
	pre.synopsis {margin-left:32px;}
	
	
	.categorytitle {margin-top:8px; padding-top:0px;}
	.categorylist {background-color: #e1e6f2;}
 	</style>
</head>
<body>
<a name="top_of_page"></a><p style="font-size:1px;"></p>
<h1 class="reftitle">contains</h1>
<h2>Purpose</h2>
<p>Test if a polyhedron/point is contained inside polyhedron.</p>
<h2>Syntax</h2>
<pre class="synopsis">tf = P.contains(S)</pre>
<pre class="synopsis">tf = P.contains(S, fastbreak)</pre>
<pre class="synopsis">tf = contains(P, S, fastbreak)</pre>
<pre class="synopsis">P &gt; S</pre>
<pre class="synopsis">P &gt;= S</pre>
<pre class="synopsis">S &lt; P</pre>
<pre class="synopsis">S &lt;= P</pre>
<h2>Description</h2>
<p></p>
      Check if the polyhedron or the point <tt>S</tt> is contained inside the polyhedron <tt>P</tt>.
      The result it the logical statement if <img src="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains1.png" alt="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains1.png"> and false otherwise.
      
      <tt>S</tt> can be given as polyhedron, it can be a point given as a column (or set of points concatenated column-wise).

      Notes:
      <ul>
          
         <li> 
            <tt>P.contains(S)</tt> with <tt>S</tt> a point assumes that <tt>S</tt> is a column vector. No automatic transposition is performed! </li>
          
         <li> 
            <tt>P.contains(S)</tt> with <tt>S</tt> a matrix of points assumes that the points are stored column-wise. No automatic transposition is performed! </li>
          
         <li> If <tt>P</tt> is an array, <tt>P.contains(S)</tt> returns a <img src="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains2.png" alt="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains2.png"> matrix of logicals, where <img src="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains3.png" alt="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains3.png"> is the number of elements of 
          <tt>P</tt> and <img src="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains4.png" alt="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains4.png"> the number of points (i.e., the no. of columns) in <tt>S</tt>. </li>
      
      </ul>
      
      Remember that testing the set membership is numerically sensitive and depends on the settings of the absolute and
      relative tolerances.    
  <h2>Input Arguments</h2>
<table cellspacing="0" class="body" cellpadding="4" border="0" width="100%">
<colgroup>
<col width="31%">
<col width="69%">
</colgroup>
<tbody>
<tr valign="top">
<td><tt>P</tt></td>
<td>
<p></p>polyhedron or an array of polyhedra with <tt>m</tt> elements<p>
	    		Class: <tt>Polyhedron</tt></p>
</td>
</tr>
<tr valign="top">
<td><tt>S</tt></td>
<td>
<p></p>Polyhedron or a polyhedron array or a set of points. 
    Multiple points must be concatenated in a matrix column-wise, where the number of rows corresponds to the dimension of <tt>P</tt> and 
    the number of columns gives the number of points to test.
    No automatic transposition is performed!
    <p>
	    		Class: <tt>Polyhedron or double</tt></p>
</td>
</tr>
<tr valign="top">
<td><tt>fastbreak</tt></td>
<td>
<p></p> A logical flag. If true it indicates that the set membership test should be terminated as soon as at least one element of <tt>P</tt> contains
    the point <tt>S</tt>.
    <p>
	    		Class: <tt>logical</tt><p>Allowed values:</p><ul>
<li><tt>0</tt></li>
<li><tt>1</tt></li>
</ul></p>
<p>
	    		Default: 0</p>
</td>
</tr>
</tbody>
</table>
<h2>Output Arguments</h2>
<table cellspacing="0" class="body" cellpadding="4" border="0" width="100%">
<colgroup>
<col width="31%">
<col width="69%">
</colgroup>
<tbody><tr valign="top">
<td><tt>tf</tt></td>
<td>
<p></p>True if <img src="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains5.png" alt="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains5.png"> and false otherwise.
        <ul>
            
            <li>
                If <tt>S</tt> is a single point or a single polyhedron:
                <tt>status</tt> is a <img src="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains6.png" alt="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains6.png"> vector of <tt>true/false</tt>, 
                <tt>status(i)=true</tt> iff <tt>P(i)</tt> contains <tt>S</tt>.
            </li>
            
            <li>
                If <tt>S</tt> is a matrix of points (i.e., <tt>S = [s_1, ..., s_n]</tt>)
                <tt>status</tt> is a <img src="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains7.png" alt="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains7.png"> matrix of <tt>true/false</tt>, 
                <tt>status(i, j)=true</tt> iff <tt>P(i)</tt> contains point <tt>S(:, j)</tt>.
            </li>
            
            <li>
                If <tt>S</tt> is a polyhedron, then <tt>P.contains(x)</tt> iff <img src="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains8.png" alt="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains8.png">
            
            </li>
        
         </ul>

      <p>
	    		Class: <tt>logical</tt><p>Allowed values:</p><ul>
<li><tt>true</tt></li>
<li><tt>false</tt></li>
</ul></p>
</td>
</tr></tbody>
</table>
<h2>Example(s)</h2>
<h3>Example 
				1</h3>Create two polytopes:<pre class="programlisting">P = ExamplePoly.poly3d_sin('d',3);</pre>
<pre class="programlisting"></pre>
<pre class="programlisting">S = ExamplePoly.poly3d_sin('d',3); S = S.affineMap(eye(3)*2);</pre>
<pre class="programlisting"></pre>Compare polytopes:<pre class="programlisting">P.contains(S)</pre>
<pre class="programlisting">
ans =

     0

</pre>
<pre class="programlisting">S.contains(P)</pre>
<pre class="programlisting">
ans =

     1

</pre>Plot the result<pre class="programlisting">plot([P,S],'alpha',0.3);</pre>
<pre class="programlisting"></pre>
<p class="programlistingindent"><img src="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains_img_1.png" alt="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains_img_1.png" width="60%"></p>
<h3>Example 
				2</h3>Create two polyhedra:<pre class="programlisting">P = ExamplePoly.randHrep;</pre>
<pre class="programlisting"></pre>
<pre class="programlisting">S = P + ExamplePoly.randVrep('n',1,'nr',1);</pre>
<pre class="programlisting"></pre>Compare polytopes:<pre class="programlisting">P.contains(S)</pre>
<pre class="programlisting">
ans =

     0

</pre>
<pre class="programlisting">S.contains(P)</pre>
<pre class="programlisting">
ans =

     0

</pre>Plot the result<pre class="programlisting">plot([S P]);</pre>
<pre class="programlisting"></pre>
<p class="programlistingindent"><img src="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains_img_2.png" alt="../../../../../../fig/mpt/modules/geometry/sets/@Polyhedron/contains_img_2.png" width="60%"></p>
<h3>Example 
				3</h3> Create random polyhedron. <pre class="programlisting"> P = ExamplePoly.randVrep; </pre>
<pre class="programlisting"></pre> Grid the polyhedron with 5 point over dimension.<pre class="programlisting"> x =  P.grid(5); </pre>
<pre class="programlisting"></pre> Test whether each grid point is contained in the polyhedron <tt>P</tt>. <pre class="programlisting"> P.contains(x') </pre>
<pre class="programlisting">
ans =

     1     1     1     1     1     1     1     1

</pre>
<h2>See Also</h2>
<a href="./interiorpoint.html">interiorpoint</a>, <a href="./le.html">le</a>, <a href="./lt.html">lt</a>, <a href="./ge.html">ge</a>, <a href="./gt.html">gt</a><p></p>
<table class="nav" summary="Navigation aid" border="0" width="100%" cellpadding="0" cellspacing="0"><tr valign="top">
<td align="left" width="20">
<a href="isneighbor.html" class="button">&#9664;</a>  </td>
<td align="left">isneighbor</td>
<td>  </td>
<td align="right">isadjacent</td>
<td align="right" width="20"><a href="isadjacent.html" class="button">&#9654;</a></td>
</tr></table>
<br><p>©  <b>2010-2013</b>     Colin Neil Jones: EPF Lausanne,    <a href="mailto:colin.jones@epfl.ch">colin.jones@epfl.ch</a></p>
<p>©  <b>2003-2013</b>     Michal Kvasnica: STU Bratislava,    <a href="mailto:michal.kvasnica@stuba.sk">michal.kvasnica@stuba.sk</a></p>
<p>©  <b>2010-2013</b>     Martin Herceg: ETH Zurich,    <a href="mailto:herceg@control.ee.ethz.ch">herceg@control.ee.ethz.ch</a></p>
</body>
</html>
